package com.library.servlet.student;

import com.library.service.student.BookService;
import com.library.servlet.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/student/book/*")
public class BookServlet extends BaseServlet {
    private BookService bookService = new BookService();

    // 书籍多条件查询
    protected void queryBooks(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String author = req.getParameter("author");
        String isbn = req.getParameter("isbn");
        String publisher = req.getParameter("publisher");
        String bname = req.getParameter("bname");
        req.setAttribute("bookList", bookService.queryBooks(author, isbn, publisher, bname));
        req.setAttribute("author", author);
        req.setAttribute("isbn", isbn);
        req.setAttribute("publisher", publisher);
        req.setAttribute("bname", bname);
        req.getRequestDispatcher("/WEB-INF/student/queryBooks.jsp").forward(req, resp);
    }
} 